package com.dt.platform.generator.module.hr;


import com.dt.platform.constants.db.HrTables;
import com.dt.platform.constants.enums.common.StatusEnableEnum;
import com.dt.platform.domain.hr.PaperQuestion;
import com.dt.platform.domain.hr.meta.LearnPaperMeta;
import com.dt.platform.domain.hr.meta.PaperQuestionRelMeta;
import com.dt.platform.generator.config.Config;
import com.dt.platform.hr.page.LearnPaperPageController;
import com.dt.platform.proxy.hr.LearnPaperServiceProxy;
import com.github.foxnic.generator.builder.view.config.DatePickerType;
import com.github.foxnic.generator.config.WriteMode;
import org.github.foxnic.web.domain.hrm.Employee;
import org.github.foxnic.web.domain.system.DictItem;
import org.github.foxnic.web.domain.system.meta.DictItemMeta;
import org.github.foxnic.web.proxy.system.DictItemServiceProxy;


public class ALearnPaperGtr extends BaseCodeGenerator {
    public ALearnPaperGtr() {
        super(HrTables.HR_LEARN_PAPER.$TABLE,"811268060357853184");
    }

    public void generateCode() throws Exception {
        System.out.println(this.getClass().getName());

        cfg.view().field(HrTables.HR_LEARN_PAPER.ID).basic().hidden(true);
        cfg.view().field(HrTables.HR_LEARN_PAPER.NAME).search().fuzzySearch();


        cfg.getPoClassFile().addListProperty(PaperQuestion.class,"paperQuestionList","paperQuestionList","paperQuestionList");


        cfg.getPoClassFile().addSimpleProperty(DictItem.class,"typeDict","typeDict","typeDict");

        cfg.getPoClassFile().addSimpleProperty(String.class,"selectedCode","selectedCode","selectedCode");
        cfg.view().field(HrTables.HR_LEARN_PAPER.NAME).search().fuzzySearch();
        cfg.view().field(HrTables.HR_LEARN_PAPER.NOTES).search().fuzzySearch();
        cfg.view().field(HrTables.HR_LEARN_PAPER.NAME).form().validate().required();
         cfg.view().field(HrTables.HR_LEARN_PAPER.CREATE_TIME).search().range();
        cfg.view().search().inputLayout(
                new Object[]{
                        HrTables.HR_LEARN_PAPER.TYPE,
                        HrTables.HR_LEARN_PAPER.NAME,
                        HrTables.HR_LEARN_PAPER.CREATE_TIME,
                }
        );

        //hr_paper_question_type

        cfg.view().field(HrTables.HR_LEARN_PAPER.TYPE).form().validate().required().form().selectBox()
                .queryApi(DictItemServiceProxy.QUERY_PAGED_LIST+"?dictCode=hr_paper_question_type")
                .paging(true).filter(true).toolbar(false)
                .valueField(DictItemMeta.CODE).
                textField(DictItemMeta.LABEL).
                fillWith(LearnPaperMeta.TYPE_DICT).muliti(false);


        cfg.view().list().disableBatchDelete();


        cfg.view().field(HrTables.HR_LEARN_PAPER.UPDATE_BY).form().table().disable(true);
        cfg.view().field(HrTables.HR_LEARN_PAPER.UPDATE_BY).form().table().disable(true);
        cfg.view().field(HrTables.HR_LEARN_PAPER.UPDATE_TIME).form().table().disable(true);
        cfg.view().field(HrTables.HR_LEARN_PAPER.NOTES).form().table().disable(true);
        cfg.view().field(HrTables.HR_LEARN_PAPER.NOTES).form().textArea().height(80);

        cfg.view().search().labelWidth(1,Config.searchLabelWidth);
        cfg.view().search().labelWidth(2,Config.searchLabelWidth);
        cfg.view().search().labelWidth(3,Config.searchLabelWidth);
        cfg.view().search().labelWidth(4,Config.searchLabelWidth);
        cfg.view().search().inputWidth(Config.searchInputWidth);


        cfg.view().search().rowsDisplay(1);
        cfg.view().formWindow().width("80%");;
        cfg.view().formWindow().bottomSpace(50);

        cfg.view().form().addGroup(null,
                new Object[] {
                        HrTables.HR_LEARN_PAPER.NAME,
                },
                new Object[] {
                        HrTables.HR_LEARN_PAPER.TYPE,
                }
        );
        cfg.view().form().addGroup(null,
                new Object[] {
                        HrTables.HR_LEARN_PAPER.NOTES,
                }
        );

        cfg.view().list().addToolButton("上传","uploadPaper","uploadPaper");
        cfg.view().list().addToolButton("下载","downloadPaper","downloadPaper");
        cfg.view().list().operationColumn().addActionButton("导入题库","importQuestion","importQuestion");
        cfg.view().list().operationColumn().addActionButton("导出题库","exportQuestion","exportQuestion");
        cfg.view().list().operationColumn().addActionButton("题库验证","validQuestion","validQuestion");
        cfg.view().form().addPage("questionList","题目列表","questionList");

        cfg.view().list().excel(true,true);


        //文件生成覆盖模式
        cfg.overrides()
                .setServiceIntfAnfImpl(WriteMode.IGNORE) //服务与接口
                .setControllerAndAgent(WriteMode.IGNORE) //Rest
                .setPageController(WriteMode.IGNORE) //页面控制器
                .setBpmEventAdaptor(WriteMode.COVER_EXISTS_FILE)
                .setFormPage(WriteMode.COVER_EXISTS_FILE) //表单HTML页
                .setListPage(WriteMode.COVER_EXISTS_FILE) //列表HTML页
                .setExtendJsFile(WriteMode.WRITE_TEMP_FILE);
        //生成代码
        cfg.buildAll();
    }

    public static void main(String[] args) throws Exception {
        ALearnPaperGtr g=new ALearnPaperGtr();
        //生成代码
        g.generateCode();

        //移除之前生成的菜单，视情况执行
       // System.out.println("############"+g.getTablePrefix());
       // g.removeByBatchId("801716675761143808");
      //  //生成菜单
      // g.generateMenu(LearnPaperServiceProxy.class, LearnPaperPageController.class);
    }
}
